home *** CD-ROM | disk | FTP | other *** search
-
- /**************************************************************************
- * *
- * This code is developed by Adam Li. This software is an *
- * implementation of a part of one or more MPEG-4 Video tools as *
- * specified in ISO/IEC 14496-2 standard. Those intending to use this *
- * software module in hardware or software products are advised that its *
- * use may infringe existing patents or copyrights, and any such use *
- * would be at such party's own risk. The original developer of this *
- * software module and his/her company, and subsequent editors and their *
- * companies (including Project Mayo), will have no liability for use of *
- * this software or modifications or derivatives thereof. *
- * *
- * Project Mayo gives users of the Codec a license to this software *
- * module or modifications thereof for use in hardware or software *
- * products claiming conformance to the MPEG-4 Video Standard as *
- * described in the Open DivX license. *
- * *
- * The complete Open DivX license can be found at *
- * http://www.projectmayo.com/opendivx/license.php . *
- * *
- **************************************************************************/
-
- /************************************************************************
- *
- * DriverProc.cpp, Main Driver Process
- *
- * Copyright (C) 2000 DivX Networks
- *
- * Adam Li
- *
- * DivX Advance Research Center <darc@projectmayo.com>
- *
- ************************************************************************/
-
- // This is the main entrance and message loop of the codec driver.
- // It dispatchs the message, and calls the corresponding functions of the driver.
- // The maintains functions are in maintain.cpp and config_dialog.cpp.
- // The encoder functions are in enc_engine.cpp.
- // The decoder functions are in dec_engine.cpp.
- // It initializes the lookup table for RGB<->YUV conversion.
-
- #include "StdAfx.h"
- #include "codec.h"
-
- /**
- * personalized messages for the decoder
- **/
-
- #define DIVXSET_POSTPROCESSING (ICM_USER+80) // set postprocessing level
-
- /* These has to be global, since the windows open one codec instance
- for configure, then use another codec instance for encoding. */
- long rc_period = 300;
- long bitrate = 780000;
- int search_range = 128;
- int max_quantizer = 15;
- int min_quantizer = 2;
-
- __declspec(dllexport) LRESULT WINAPI DriverProc(DWORD dwDriverID, HDRVR hDriver, UINT uiMessage, LPARAM lParam1, LPARAM lParam2)
- {
- codec *cdx = (codec *)(UINT)dwDriverID;
- ICOPEN *icinfo = (ICOPEN *)lParam2;
- switch (uiMessage) {
-
- /****************************************
-
- decompress messages
-
- ****************************************/
-
- case ICM_DECOMPRESS:
- return cdx->decDecode(lParam1, lParam2);
-
- case ICM_DECOMPRESS_GET_PALETTE:
- case ICM_DECOMPRESS_SET_PALETTE:
- return ICERR_UNSUPPORTED;
-
- case ICM_DECOMPRESS_QUERY:
- return cdx->decQuery(lParam1, lParam2);
-
- case ICM_DECOMPRESS_GET_FORMAT:
- return cdx->decGetFormat(lParam1, lParam2);
-
- case ICM_DECOMPRESS_BEGIN:
- return cdx->decBegin(lParam1, lParam2);
-
- case ICM_DECOMPRESS_END:
- return cdx->decEnd(lParam1, lParam2);
-
- // decoder settings messages
-
- case DIVXSET_POSTPROCESSING:
- return cdx->decSetPostProcessing(lParam1, lParam2);
-
- /****************************************
-
- standard driver messages
-
- ****************************************/
-
- case DRV_LOAD:
- return (LRESULT)1L;
-
- case DRV_FREE:
- return (LRESULT)1L;
-
- case DRV_OPEN:
- if (icinfo && icinfo->fccType != ICTYPE_VIDEO) return NULL;
- cdx = new codec;
- if (icinfo) icinfo->dwError = cdx ? ICERR_OK : ICERR_MEMORY;
- return (LRESULT)(DWORD)(UINT) cdx;
-
- case DRV_CLOSE:
- // delete(cdx); // this (occationally) causes problem at closing
- return (LRESULT)1L;
-
- case DRV_DISABLE:
- case DRV_ENABLE:
- return (LRESULT)1L;
-
- case DRV_INSTALL:
- case DRV_REMOVE:
- return (LRESULT)DRV_OK;
-
- case DRV_QUERYCONFIGURE:
- return (LRESULT)1L; // does support drive configure with the about box
-
- case DRV_CONFIGURE:
- return cdx->about(lParam1,lParam2);
-
- /****************************************
-
- state messages
-
- ****************************************/
-
- case ICM_ABOUT:
- return cdx->about(lParam1,lParam2);
-
- case ICM_CONFIGURE:
- return cdx->config(lParam1, lParam2);
-
- case ICM_GETSTATE:
- if (lParam1 == NULL) return 0;
- else return ICERR_OK;
-
- case ICM_SETSTATE:
- return 0;
-
- case ICM_GET:
- return 0;
-
- case ICM_GETQUALITY:
- case ICM_SETQUALITY:
- case ICM_GETDEFAULTQUALITY:
- case ICM_GETDEFAULTKEYFRAMERATE:
- return ICERR_UNSUPPORTED;
-
- case ICM_GETINFO:
- return cdx->getInfo(lParam1, lParam2);
-
- /****************************************
-
- compression messages
-
- ****************************************/
-
- case ICM_COMPRESS_QUERY:
- return cdx->encQuery(lParam1, lParam2);
-
- case ICM_COMPRESS_GET_FORMAT:
- return cdx->encGetFormat(lParam1, lParam2);
-
- case ICM_COMPRESS_GET_SIZE:
- return cdx->encGetSize(lParam1, lParam2);
-
- case ICM_COMPRESS_FRAMES_INFO:
- return cdx->encFramesInfo(lParam1, lParam2);
-
- case ICM_COMPRESS_BEGIN:
- return cdx->encBegin(lParam1, lParam2);
-
- case ICM_COMPRESS:
- return cdx->encEncode(lParam1, lParam2);
-
- case ICM_COMPRESS_END:
- return cdx->encEnd(lParam1, lParam2);
-
- }
-
- if (uiMessage < DRV_USER)
- return DefDriverProc(dwDriverID, hDriver, uiMessage, lParam1, lParam2);
- else
- return ICERR_UNSUPPORTED;
- }
-
-